<template>
	<view class="harassmentnumber-container">
		<view class="panel">
			<view class="item">
				<text>手机号:</text><input type="text" @input="onKeyInput" placeholder="请输入手机号" v-model="mark" />
			</view>
			<view>
				<button type="primary" @click="getHarassPhone">查询</button>
			</view>
			<view class="item" v-if="this.status==true">电话<text class="textNum">{{this.number}}</text>为骚扰电话,被举报了<text
					class="textNum">{{this.num}}</text>次</view>
			<view v-else>电话为正常电话</view>
		</view>
	</view>

</template>

<script>
	import service from '../../utils/http.js'
	export default {
		data() {
			return {
				info: {},
				num: 0,
				number: '17000138401',
				status: false
			};
		},
		onLoad() {
			this.getHarassPhone()
		},
		methods: {
			onKeyInput(event) {
				this.number = event.detail.value
				console.log(this.number)
			},
			getHarassPhone() {
				const number = '17000138401' //15311510653
				service.get('api/search/harassPhone?phone=' + this.number)
					.then(response => {
						console.log(response)
						this.info = response
						if (response.msg == 'success') {
							const result = response.result
							console.log(result)
							this.num = response.result.num
							this.status = response.result.status
						}
					})
					.catch(error => {
						console.error(error);
					});
			}
		}
	}
</script>

<style lang="scss">
	.harassmentnumber-container {
		margin: 0 20px 0 20px;

		.item {
			display: flex;
			flex-direction: row;

			.textNum {
				color: red;
			}
		}
	}
</style>